//
//  HouseTypeData.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/5/12.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "HouseTypeData.h"
#import "disDescModel.h"
#import "StringTool.h"

@implementation HouseTypeData

-(instancetype)initWithDic:(NSDictionary *)dic;
{
    
    
    if (self = [super init])
    {
        self.housingId = [dic[@"housingId"]integerValue];
        self.countryName = dic[@"countryName"];
        self.stateName = dic[@"stateName"];
        self.cityName = dic[@"cityName"];
        self.housingName= dic[@"housingName"];
        
        
        self.totalAmountCNY = [dic[@"totalAmountCNY"]integerValue];
        self.totalAmountUSD = [dic[@"totalAmountUSD"]integerValue];;
        self.zip = [dic[@"zip"]integerValue];
        self.status = dic[@"status"];
        self.decorationName = dic[@"decorationName"];
        self.floor = [dic[@"floor"]integerValue];
        
        
        self.expectRent = [dic[@"expectRent"]floatValue];
        self.expectYield = [dic[@"expectYield"]floatValue];
        self.longitude = [dic[@"longitude"]doubleValue];
        self.latitude = [dic[@"latitude"]doubleValue];
        
        
        //        self.houseId = dic[@"houseId"];
        self.bedRoom = [dic[@"bedRoom"]integerValue];
        self.bathRoom = [dic[@"bathRoom"]integerValue];
        self.garage = [dic[@"garage"]integerValue];
        self.typeName = dic[@"typeName"];
        self.areaMi = [dic[@"areaMi"]integerValue];
        self.businessNo = dic[@"businessNo"];
        
        
        self.lTypeName = dic[@"lTypeName"];
        self.houseTypeName = dic[@"houseTypeName"];
        
        if (![dic[@"surSchool"] isKindOfClass:[NSNull class]] && dic[@"surSchool"] != nil && ![dic[@"surSchool"] isEqualToString:@""])
        {
            self.nearbyArr = [[NSMutableArray alloc]init];
            
            if (![dic[@"surSchoolDetail"] isKindOfClass:[NSNull class]] && dic[@"surSchoolDetail"] != nil && ![dic[@"surSchoolDetail"] isEqualToString:@""])
            {
                NearbyCellData *data1 = [NearbyCellData nearbyCellWithTitle:@"周边学校" WithDetail:dic[@"surSchool"] WithMoreDetail:dic[@"surSchoolDetail"]];
                [self.nearbyArr addObject:data1];
            }else
            {
                NearbyCellData *data1 = [NearbyCellData nearbyCellWithTitle:@"周边学校" WithDetail:dic[@"surSchool"] WithMoreDetail:nil];
                [self.nearbyArr addObject:data1];
            }
           
        }
       
        if (![dic[@"aroundEnv"] isKindOfClass:[NSNull class]] && dic[@"aroundEnv"] != nil && ![dic[@"aroundEnv"] isEqualToString:@""])
        {
            NearbyCellData *data2 = [NearbyCellData nearbyCellWithTitle:@"周边环境" WithDetail:dic[@"aroundEnv"] WithMoreDetail:nil];
            [self.nearbyArr addObject:data2];

        }
        if (![dic[@"communityFac"] isKindOfClass:[NSNull class]] && dic[@"communityFac"] != nil&& ![dic[@"communityFac"] isEqualToString:@""])
        {
            NearbyCellData *data4 = [NearbyCellData nearbyCellWithTitle:@"社区设施" WithDetail:dic[@"communityFac"] WithMoreDetail:nil];
            [self.nearbyArr addObject:data4];
            
        }

        if (![dic[@"surroundingFac"] isKindOfClass:[NSNull class]] && dic[@"surroundingFac"] != nil && ![dic[@"surroundingFac"] isEqualToString:@""])
        {
            NearbyCellData *data3 = [NearbyCellData nearbyCellWithTitle:@"周边配套" WithDetail:dic[@"surroundingFac"] WithMoreDetail:nil];
            [self.nearbyArr addObject:data3];
        }

        if (![dic[@"leisureFac"] isKindOfClass:[NSNull class]] && dic[@"leisureFac"] != nil && ![dic[@"leisureFac"] isEqualToString:@""])
        {
            NearbyCellData *data5 = [NearbyCellData nearbyCellWithTitle:@"休闲设施" WithDetail:dic[@"leisureFac"] WithMoreDetail:nil];
            [self.nearbyArr addObject:data5];

        }

        if (![dic[@"healthFit"]isKindOfClass:[NSNull class]] && dic[@"healthFit"] != nil && ![dic[@"healthFit"] isEqualToString:@""])
        {
            NearbyCellData *data6 = [NearbyCellData nearbyCellWithTitle:@"健康健身" WithDetail:dic[@"healthFit"] WithMoreDetail:nil];
            [self.nearbyArr addObject:data6];
            
        }

        if (![dic[@"spfac"]isKindOfClass:[NSNull class]] && dic[@"spfac"] != nil&& ![dic[@"spfac"] isEqualToString:@""])
        {
            NearbyCellData *data7 = [NearbyCellData nearbyCellWithTitle:@"汽电设施" WithDetail:dic[@"spfac"] WithMoreDetail:nil];
            [self.nearbyArr addObject:data7];
            
        }
        
        if (![StringTool isBlankString:dic[@"housingFac"]]) {
            
            NearbyCellData *data8 = [NearbyCellData nearbyCellWithTitle:@"房源配套" WithDetail:dic[@"housingFac"] WithMoreDetail:nil];
            [self.nearbyArr addObject:data8];
            
        }
       
        self.thumb = dic[@"thumb"];
        
        
        self.houseTagsArr = dic[@"houseTags"];
        self.fangxingPicsArr = dic[@"fangxingPics"];
        self.fangyuanPicsArr = dic[@"fangyuanPics"];
        
        
        self.detail = dic[@"detail"];
        self.detailEnglish = dic[@"detailEnglish"];
        
        
        NSArray *arr = [NSArray arrayWithArray:dic[@"infoDtos"]];
        NSMutableArray *arrM = [NSMutableArray array];
        for (NSDictionary *dic in arr)
        {
            disDescModel *model = [disDescModel disDescModelWithDic:dic];
            [arrM addObject:model];
        }
        self.disDescArr = [NSMutableArray arrayWithArray:arrM];
        
    }
    return self;
    
}
+(instancetype)houseTypeViewModelWithDic:(NSDictionary *)dic;
{
    return [[self  alloc]initWithDic:dic];
}

@end
